﻿<%@ Page language="C#" MasterPageFile="~masterurl/default.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" meta:webpartpageexpansion="full" meta:progid="SharePoint.WebPartPage.Document" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %> 

<asp:Content ID="Content1" ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">
	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
	
	<script type="text/javascript">
		var _els = {},
			_requestUrl = '';

		function getGroups(e) {
			e.preventDefault();
			_els.results.empty();

			$.post(_requestUrl,
					{ op: 'GetSiteAccessGroups', includeUsers: true })
				.done(function (data) {
					$.each(data.d.results, function (i, el) {
						var li = $("<li/>")
									.append(el.Id + ": " + el.DisplayName + " (" + el.LoginName + ")"),
							ul = $("<ul/>");
						$.each(el.Users, function (e, uel) {
							ul.append("<li>" + uel.Id + ": " + uel.DisplayName + " (" + uel.LoginName + ")" + "</li>");
						});
						li.append(ul)
							.appendTo(_els.results);
					});
				})
				.fail(function (error) {
				});
		}
		function getTime(e) {
			e.preventDefault();
			_els.results.empty();

			$.post(_requestUrl,
					{ op: 'GetDateTime', format: 'dd.MM.yyyy hh:mm:ss' })
				.done(function (data) {
					$("<li/>")
						.append(data.d.results)
						.appendTo(_els.results);
				})
				.fail(function (error) {
				});
		}

		$(function () {
			_requestUrl = _spPageContextInfo.webServerRelativeUrl
							+ '/_layouts/Pdogs.ApplicationPageService/MyAppService.aspx';
			_els.results = $("#results");
			_els.label = $("#label").text(_requestUrl);

			$("#getgroups").click(getGroups);
			$("#gettime").click(getTime);
		});
	</script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderId="PlaceHolderMain" runat="server">
	<input id="getgroups" type="button" value="Get Groups" />&nbsp;<input id="gettime" type="button" value="Get Time" />
	<div id="label" style="padding-top:10px;">&nbsp;</div>
	<ul id="results">
		<li><i>Click on Get Groups</i></li>
	</ul>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
Application Page as a Service - 
<SharePoint:ProjectProperty ID="ProjectProperty1" Property="Title" runat="server"/>
</asp:Content>

<asp:Content ID="Content11" ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">
Application Page as a Service
</asp:Content>
